<?php session_start();
	
	include('planning.php');
	include('PlanningCellule.php');
	include_once ('../orm/bootstrap.php');

	class Document
	{
		protected $css;
		protected $siteUrl ='http://localhost/Dansin_v2';	
		protected $user_level = 0;
		protected $user_first_name = '';
		protected $user_last_name = '';
		protected $user_id;
		protected $access_level = 0;
		
		public function __construct()
		{
			if(isset($_SESSION['level'])){
				$this->user_level = $_SESSION['level'];
				$this->user_first_name = $_SESSION['prenom'];
				$this->user_last_name = $_SESSION['nom'];
				$this->user_id = $_SESSION['id'];
			}
		}
		
		public function begin($level = 0)
		{
			$this->access_level = $level;
			
			$this->header_view();
			if(!$this->menu_view()){
				$this->end();
			}
		}
		
		public function end()
		{
			$this->footer_view();
		}
		
		public function header_view()
		{
			if($this->user_level > 0){
				$this->header_connected();
			}else{
				$this->header_deconnected();
			}
		}
		
		public function header_connected()
		{
			$html=
<<<HEREDOC
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmins="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link rel="stylesheet" href="../css/style.css" />
		<style type="text/css">
			@import "../js/dojo/dijit/themes/soria/soria.css";
			@import "../js/dojo/dijit/themes/tundra/tundra.css" />
			@import "../js/dojo/dojo/resources/dojo.css";
		</style>
	    <script type="text/javascript" src="../js/fonctionJs.js" ></script>
	    <script type="text/javascript" src="../js/dojo/dojo/dojo.js" djConfig="parseOnLoad:true"></script>
	    <script type="text/javascript">
	    	dojo.require("dijit.form.ValidationTextBox");
	    	dojo.require("dijit.form.NumberTextBox");
	    	dojo.require("dijit.form.TextBox");
	    	dojo.require("dojo.parser");
	    	dojo.require("dijit.form.Form");
	    	dojo.require("dijit.form.Button");
	    	dojo.require("dojox.validate.regexp");
	    </script>
	    
		<title>Dans'in</title>
	</head>
	<body>
	
		<div id="page">
		
				<div id="header">
					<h1>DANSIN</h1>
					<h2>La danse de salon et bien plus encore</h2>
					<div class="login_connected">
						Bienvenue $this->user_first_name<br/>
						<a href="./user_controller.php?action=logout"><img src="../images/deconnecter.png">Deconnexion</a>
					</div>
HEREDOC;
			echo $html;	
			switch($this->user_level){
				case 1: $this->header_level_1();	
				break;
				case 2: $this->header_level_2();	
				break;
				case 3: $this->header_level_3();	
			}
		}
		
		public function header_deconnected()
		{
			$html=
<<<HEREDOC
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmins="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	    <link rel="stylesheet" href="../css/style.css" />
		<style type="text/css">
			@import "../js/dojo/dijit/themes/soria/soria.css";
			@import "../js/dojo/dijit/themes/tundra/tundra.css" />
			@import "../js/dojo/dojo/resources/dojo.css";
		</style>
	   
	    <script type="text/javascript" src="../js/dojo/dojo/dojo.js" djConfig="parseOnLoad:true"></script>
	    <script type="text/javascript">
	    	dojo.require("dijit.form.ValidationTextBox");
	    	dojo.require("dijit.form.NumberTextBox");
	    	dojo.require("dijit.form.TextBox");
	    	dojo.require("dojo.parser");
	    	dojo.require("dijit.form.Form");
	    	dojo.require("dijit.form.Button");
   			dojo.require("dojox.validate.regexp");
   			dojo.require("dojox.form.PasswordValidator");
	    </script>	
	     <script type="text/javascript" src="../js/fonctionJs.js" ></script>
		<title>Dans'in</title>
	</head>
	<body>
	
		<div id="page">
		
				<div id="header">
					<h1>DANSIN</h1>
					<h2>La danse de salon et bien plus encore</h2>
					<div class="nav">
						<dl>
							<dt><a href="./user_controller.php?action=index">Accueil</a></dt>
							<dt><a href="./user_controller.php?action=inscription">Inscription</a></dt>
						</dl>
					</div>
					<div class="login" class="thundra">
						<form method=post action="./user_controller.php?action=connexion" enctype="multipart/form-data" id="formConnexion" dojoType="dijit.form.Form">
							<table BORDER=0>
								<tr>
									<td>
										<label>Email</label>
									</td>
									<td>
										<input id="email" type="text" name="email" class="long" value=""
    														dojoType="dijit.form.ValidationTextBox"
    														trim="true"
    														required="true"
    														invalidMessage="Email non valide." />
									</td>
								</tr>
								<tr>
									<td>
										<label>Mot de passe</label>
									</td>
									<td>
										<input type="password"
    														id="password"
    														name="password"
    														dojoType="dijit.form.ValidationTextBox"
    														required="true"
    														trim="true"
    														invalidMessage="Le mot de passe est nécessaire" />
    								</td>
								</tr>
							</table>
							<input type="submit" label="connexion" dojoType="dijit.form.Button" onClick="dijit.byId('formConnexion').validate();"/>
						</form>
					</div>
				</div>	

HEREDOC;
			echo $html."<br/>";	
		}
		
		
		public function footer_view()
		{
			$html=
<<<HEREDOC
			
		
				
		</div>
						<div id="footer">
					<p>© 2012 <a href="#">BDEG</a></p>
					<p><a href="#">Valid XHTML 1.0 Strict</a> | <a href="#">Valid CSS</a></p>
		</div>	
	</body>
</html>
HEREDOC;
			echo $html."<br/>";
		}
		
		/*
		 * 	MENU HEADER EN FONCTION DU NIVEAU (1-2-3)
		 */
		public function header_level_1()
		{
			$html=
<<<HEREDOC
			
			<div class="nav">
				<dl>
					<dt><a href="./user_controller.php?action=index">Accueil</a></dt>
					<dt><a href="./user_controller.php?action=cours">Mes Cours</a></dt>
					<dt><a href="./user_controller.php?action=informations">Informations Personelles</a></dt>
				</dl>
			</div>
		</div>
HEREDOC;
			echo $html."<br/>";
		}
		
		public function header_level_2()
		{
			$html=
<<<HEREDOC
				
			<div class="nav">
				<dl>
					<dt><a href="./user_controller.php?action=index">Accueil</a></dt>
					<dt><a href="./user_controller.php?action=planning">Mon Planning</a></dt>
					<dt><a href="./user_controller.php?action=informations">Informations Personelles</a></dt>
				</dl>
			</div>
		</div>
HEREDOC;
			echo $html."<br/>";
		}
		
		public function header_level_3()
		{
			$html=
<<<HEREDOC
				<div class="nav">
					<dl>
						<dt><a href="./user_controller.php?action=index">Accueil</a></dt>
						<dt><a href="./user_controller.php?action=CoursGestion">Cours</a></dt>
						<dt><a href="./user_controller.php?action=ProfesseurGestion">Professeurs</a></dt>
						<dt><a href="./user_controller.php?action=AdherentGestion">Adhérents</a></dt>
						<dt><a href="./user_controller.php?action=informations">Informations Personelles</a></dt>
					</dl>
				</div>
			</div>
HEREDOC;
			echo $html."<br/>";
		}
		
		public function erreur_login(){
			$html=
<<<HEREDOC
		<div id="content">
				<div id="content_header">
					<h1>Erreur</h1>
				</div>
				<div id="content_content">
					<p>Votre adresse mail ou votre mot de passe ne correspond pas.</br>
					<a href="#">Mot de passe oublié ?</a></p>
				</div>
			</div>
HEREDOC;
			echo $html."<br/>";
		}	
		/***Partie non connecté formulaire d'inscription****/
		public function contenu_inscription(){
				$html=
<<<HEREDOC
<div id="contenu_inscription">
	<div id="header_page_i">
		<h1>Inscription</h1>
	</div>
										
		<div id="response"></div>	
		<div id="contenu_page_i" class="soria">	
		<form action="../orm/userData.php" id="myform" onsubmit="sendForm('myform'); return false" return false" >
			<TABLE BORDER="0">
				<tr>
					<td>				
						<label>Nom :</label>
					</td>
					<td>
						<input type="text" name="nom" id="nom" data-dojo-type="dijit.form.TextBox" required="true" 
										data-dojo-props="trim:true, propercase:true" />
					</td>
				</tr>
				<tr>
					<td>				
						<label>Pr&eacute;nom :</label>
					</td>
					<td>
						<input type="text" name="prenom" id="prenom" data-dojo-type="dijit.form.TextBox" required="true" 
										data-dojo-props="trim:true, propercase:true" />
					</td>
				</tr>				
				<tr>
					<td>
						<label>Num&eacute;ro de rue :</label>
					</td>
					<td>
						<input type="text" name="numRue" id="numRue" data-dojo-type="dijit.form.NumberTextBox" required="true" 
										constraints="{min:0,max:1000,places:0}" invalidMessage="numéro de rue incorrect"/>
					</td>
				</tr>
				<tr>
					<td>				
						<label>Rue :</label>
					</td>
					<td>
						<input type="text"" name="rue" id="rue" data-dojo-type="dijit.form.TextBox" required="true" 
										data-dojo-props="trim:true, propercase:true" />
					</td>
				</tr>	
				<tr>
					<td>
						<label>Code Postal :</label>
					</td>
					<td>
						<input type="text" name="cp" id="cp" data-dojo-type="dijit.form.NumberTextBox" 
										required="true" constraints="{min:0,max:99999,places:0}" invalidMessage="code postal incorrect"/>
					</td>
				</tr>
				<tr>
					<td>				
						<label>Ville :</label>
					</td>
					<td>
						<input type="text" name="ville" id="ville" data-dojo-type="dijit.form.TextBox" required="true" 
										data-dojo-props="trim:true, propercase:true" />
					</td>
				</tr>
				<tr>
					<td>
						<label>Telephone :</label>
					</td>
					<td>
						<input type="text" name="tel" id="tel" data-dojo-type="dijit.form.NumberTextBox" required="true" 
										constraints="{pattern:'0000000000',max:9999999999,places:0}"/>
					</td>
				</tr>
				<tr>
					<td>
						<label>Adresse Mail</label>
					</td>
					<td>
						<input type="text" name="mail" id="mail" data-dojo-type="dijit.form.ValidationTextBox" required="true" />
					</td>
				</tr>							
				<tr>
					<td>							
						<label>Mot de passe</label>						 
					</td>								
					<td>
						 <input name="password_1" id="password_1" type="password" dojoType="dijit.form.TextBox" />
					</td>
				</tr>
				<tr>
					<td>								
						 <label>Confirmer mot de passe</label>								 							   
					</td>
					<td>
						 <input name="password_confirme" id="password_confirme" type="password" dojoType="dijit.form.TextBox" />
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<br/>
						<br/>
						<center>
					</td>
				</tr>
				<input type="hidden"  name="level" id="level" value="1"/>
			</TABLE>
			<center><button type="submit" data-dojo-type="dijit.form.Button" id="submitButton" >Valider</button></center>
		</form>									
		<br>
	</div>
</div>
HEREDOC;

				
			echo $html."<br/>";
			
			/*
			 * 
			 * 	<div id="contenu_inscription">
				<div id="header_page_i">
					<h1>Inscription</h1>
				</div>
				<div id="contenu_page_i" class="soria">	
					<FORM method="post" action="adefinir" id="formulaire" data-dojo-type="dijit.form.Form">
						<br/><br/><center>
							<div data-dojo-type="dojox.form.PasswordValidator" name="password">
						<TABLE BORDER="0">
							<tr>
								<td>				
								<label>Nom :</label>
								</td>
								<td>
									<input type='text' name='name' id='nom' data-dojo-type="dijit.form.TextBox" required="true" 
										data-dojo-props="trim:true, propercase:true" />
								</td>
							</tr>
							<tr>
								<td>				
									<label>Pr&eacute;nom :</label>
								</td>
								<td>
									<input type='text' name="surname" id="prenom" data-dojo-type="dijit.form.TextBox" required="true" 
												data-dojo-props="trim:true, propercase:true" />
								</td>
							</tr>				
							<tr>
								<td>
									<label>Num&eacute;ro de rue :</label>
								</td>
								<td>
									<input type='text' name='numRue' id='numRue' data-dojo-type="dijit.form.NumberTextBox" required="true" 
												constraints="{min:0,max:1000,places:0}" invalidMessage="numéro de rue incorrect"/>
								</td>
							</tr>
							<tr>
								<td>				
									<label>Rue :</label>
								</td>
								<td>
									<input type='text' name='rue' id='rue' data-dojo-type="dijit.form.TextBox" required="true" 
												data-dojo-props="trim:true, propercase:true" />
								</td>
							</tr>	
							<tr>
								<td>
									<label>Code Postal :</label>
								</td>
								<td>
									<input type='text' name='cp' id='cp' data-dojo-type="dijit.form.NumberTextBox" 
												required="true" constraints="{min:0,max:99999,places:0}" invalidMessage="code postal incorrect"/>
								</td>
							</tr>
							<tr>
								<td>				
									<label>Ville :</label>
								</td>
								<td>
									<input type='text' name='ville' id='ville' data-dojo-type="dijit.form.TextBox" required="true" 
												data-dojo-props="trim:true, propercase:true" />
								</td>
							</tr>
							<tr>
								<td>
									<label>Telephone :</label>
								</td>
								<td>
									<input type='text' name='tel' id='tel' data-dojo-type="dijit.form.NumberTextBox" required="true" 
												constraints="{pattern:'0000000000',max:9999999999,places:0}"/>
								</td>
							</tr>
							<tr>
								<td>
									<label>Adresse Mail</label>
								</td>
								<td>
									<input type="text" name="mail" id="mail" data-dojo-type="dijit.form.ValidationTextBox" required="true" 
												data-dojo-props="regExp:'^([a-zA-Z0-9]+(([\.\-\_]?[a-zA-Z0-9]+)+)?)\@(([a-zA-Z0-9\-\_]+[\.\-\_])+[a-zA-Z]{2,4})$', 
												invalidMessage:'Invalid e-mail'"/>
								</td>
							</tr>

							
							<tr>
								<td>							
									<label>Mot de passe</label>						 
								</td>								
								<td>
								 <input type="password"  />
								</td>
								
							</tr>
								<tr>
								<td>								
									 <label>Confirmer mot de passe</label>								 							   
								</td>
								
								<td>
								 <input type="password"  />
								</td>
								
							</tr>
							
							<tr>
								<td colspan="2">
									<br/>
									<br/>
									<center>
				
								</td>
							</tr>
						</TABLE>
						 </div>
						</center>
					

			 * 
			 * 
			*/
		}
		
		public function menu_view()
		{
			if(isset($_SESSION['level']) && isset($_SESSION['first_name'])){
				$this->user_level = $_SESSION['level'];
				$this->user_first_name = $_SESSION['first_name'];
			}
			/*if($this->user_level >= $this->access_level){
				switch($this->access_level){
					case 4 : $this->menu_level_4();
					break;
					case 1 : $this->menu_level_1();
					break; 
					default : $this->menu_level_0();
				}
			}*/
			return ($this->user_level >= $this->access_level);
		}
		
		public function contenu_accueil()
		{
			$html=
<<<HEREDOC

			<div id="menu">
				<h1>Accueil</h1>
				<div class="nav">
					<dl>
						<dt><a href="./user_controller.php?action=inscription">Inscription</a></dt>
					</dl>
				</div>
			</div>
			<div id="contenu">
					<div id="header_page">
						<h1>DANSIN</h1>
					</div>
					<div id="contenu_page">
						<p><em>DANS'IN</em> regroupe les dernières nouvelles sur nos cours et nos prestations.</p>
						<ul>
							<li><em>PARTICIPEZ</em><span> aux cours</span></li>
							<li><em>DIRIGEZ</em><span> un cours.</span></li>
						</ul>							
					</div>
				</div>

HEREDOC;
			echo $html."<br/>";
		}
		
		public function contenu_connected()
		{
			$title = strtoupper($this->user_last_name)." ".strtoupper($this->user_first_name);
			switch($this->user_level){
				case 1:					
			$html=
<<<HEREDOC
			<div id="menu">
				<h1>Accueil</h1>
				<div class="nav">
					<dl>
						<dt><a href="./user_controller.php?action=cours">Mes cours</a></dt>
						<dt><a href="./user_controller.php?action=informations">Informations personnelles</a></dt>
					</dl>
				</div>
			</div>
			<div id="contenu">
					<div id="header_page">
						<h1>$title - simple adhérent</h1>
					</div>
					<div id="contenu_page">
						<p><em>DANS'IN</em> regroupe les dernières nouvelles sur nos cours et nos prestations.</p>
						<ul>
							<li><em>MODIFIEZ</em><span> vos informations personnelles.</span></li>
							<li><em>CONSULTEZ</em><span> vos horaires de cours.</span></li>
							<li><em>ACCEDEZ</em><span> à nos offres de cours.</span></li>
						</ul>							
					</div>
				</div>
HEREDOC;
					break;
				case 2:
					$html=
<<<HEREDOC
			<div id="menu">
				<h1>Accueil</h1>
				<div class="nav">
					<dl>
						<dt><a href="./user_controller.php?action=index">Accueil</a></dt>
						<dt><a href="./user_controller.php?action=planning">Mon planning</a></dt>
						<dt><a href="./user_controller.php?action=informations">Informations personnelles</a></dt>
					</dl>
				</div>
			</div>
			<div id="contenu">
					<div id="header_page">
						<h1>$title - professeur</h1>
					</div>
					<div id="contenu_page">
						<p><em>DANS'IN</em> regroupe les dernières nouvelles sur nos cours et nos prestations.</p>
						<ul>
							<li><em>MODIFIEZ</em><span> vos informations personnelles.</span></li>
							<li><em>CONSULTEZ</em><span> votre planning.</span></li>
						</ul>							
					</div>
				</div>
HEREDOC;
					break;
				case 3:
					$html=
<<<HEREDOC
			<div id="menu">
				<h1>Accueil</h1>
				<div class="nav">
					<dl>
						<dt><a href="./user_controller.php?action=index">Accueil</a></dt>
						<dt><a href="./user_controller.php?action=CoursGestion">Cours</a></dt>
						<dt><a href="./user_controller.php?action=ProfesseurGestion">Professeurs</a></dt>
						<dt><a href="./user_controller.php?action=AdherentGestion">Adhérents</a></dt>
						<dt><a href="./user_controller.php?action=informations">Informations personnelles</a></dt>
					</dl>
				</div>
			</div>
			<div id="contenu">
					<div id="header_page">
						<h1>$title - administrateur</h1>
					</div>
					<div id="contenu_page">
						<p><em>DANS'IN</em> regroupe les dernières nouvelles sur nos cours et nos prestations.</p>
						<ul>
							<li><em>MODIFIEZ</em><span> vos informations personnelles.</span></li>
							<li><em>CONSULTEZ</em><span> toutes les informations du site.</span></li>
							<li><em>MODIFIEZ</em><span> les affectations de cours.</span></li>
						</ul>							
					</div>
				</div>
HEREDOC;
			}
			echo $html."<br/>";
		}
		
		/******Partie Adherant*********/
		public function contenu_cours(){
			$liste_cours = $this->getListeCoursAdherentById($_SESSION['id']);
			$coursL = "";
			foreach($liste_cours as $cours){
				$coursL = $coursL."<tr>
					<td>".$cours[0]."</td>
					<td>".$cours[1]."</td> 
					<td>".$cours[2]."</td> 
					<td>".$cours[3]."</td> 
					<td>
						<FORM METHOD='POST' ACTION='./user_controller.php?action=desinscrire_cours_adherent' enctype='multipart/form-data' id='formConnexion' dojoType='dijit.form.Form'>
							<input type='hidden'  name='desinscrire_cours' id='desinscrire_cours' value=".$cours[4]."/>
							<center><button type='submit' id='submitButton' ;'>Desinscrire</button></center>	
						</FORM>											
					</td></tr>";
			}
	
			$html=
<<<HEREDOC
			<div id="menu">
				<h1>Cours</h1>
				<div class="nav">
					<dl>
						<dt><a href="./user_controller.php?action=cours">Mes Cours</a></dt>
						<dt><a href="./user_controller.php?action=cours_inscription">S'inscrire</a></dt>
					</dl>
				</div>
			</div>
			<div id="contenu">
				<div id="header_page">
					<h1>Mes Cours</h1>
				</div>
				<div id="contenu_page" class="soria">	
			
					<center>
					<table class ='reportTable'>
                    	<thead>
                    		<tr>
        	    				<th class="enteteTab"  >Jour</th>
             					<th class="enteteTab"  >Heure</th> 
             					<th class="enteteTab"  >Niveau</th> 
             					<th class="enteteTab"  >Danse</th</tr>
             					<th class="enteteTab"  >Désinscription</th>
             				</tr> 
             			</thead>
             			<tbody>
            				$coursL
           				</tbody>
           			</table>
           			</center>					
				</div>
			</div>

HEREDOC;
		echo $html."</br>" ;
		}
		
		public function inscription_cours(){
			$liste_cours = $this->getAllCours();
			$liste_cours_inscrits = $this->getListeCoursAdherentById($this->user_id);
			$coursL = "";
			for($i=0; $i<count($liste_cours); $i++){
				$is_inscrit = false;
				foreach ($liste_cours_inscrits as $cours_inscrit){
					if($liste_cours[$i][6] == $cours_inscrit[4]){
						$is_inscrit = true;
						break;
					}
				}
				if(!$is_inscrit){
					$coursL = $coursL.
						"<OPTION VALUE=".$liste_cours[$i][6].">".$liste_cours[$i][2]."--".$liste_cours[$i][7]."--".$liste_cours[$i][0]."--".$liste_cours[$i][1]."--".$liste_cours[$i][5]." ".$liste_cours[$i][4]."</OPTION>";
				}
			}			
		
			$html=
<<<HEREDOC
			<div id="menu">
				<h1>Cours</h1>
				<div class="nav">
					<dl>
						<dt><a href="./user_controller.php?action=cours">Mes Cours</a></dt>
						<dt><a href="./user_controller.php?action=cours_inscription">S'inscrire</a></dt>
					</dl>
				</div>
			</div>
			<div id="contenu">
				<div id="header_page">
					<h1>Inscription à un cours</h1>
				</div>
				<div id="contenu_page" class="soria">	
			
					<center>
					<FORM METHOD="POST" ACTION="./user_controller.php?action=inscrire_cours_adherent" enctype="multipart/form-data" id="formConnexion" dojoType="dijit.form.Form">
						<SELECT name="inscrire_cours">
							$coursL
						</SELECT>					
						<center><button type="submit" data-dojo-type="dijit.form.Button" id="submitButton" ;">Ajouter Cours</button></center>
					</FORM>
           			</center>					
				</div>
			</div>

HEREDOC;
		echo $html."</br>" ;			
		}
		
		public function informations(){
			
			$informations = $this->getUserById($this->user_id);
			if($informations[0]['ad_est_actif'] == '0')
				$actif = "non";
			else
				$actif = "oui";
				
			$html=
<<<HEREDOC
			<div id="menu">
				<h1>Informations</h1>
				<div class="nav">
					<dl>
						<dt><a href="./user_controller.php?action=informations">Mes informations</a></dt>
						<dt><a href="./user_controller.php?action=informationsModification">Modifiez informations</a></dt>
					</dl>
				</div>
			</div>
			<div id="contenu">
					<div id="header_page">
						<h1>Mes informations personnelles</h1>
					</div>
					<div id="contenu_page">	
						<div id="informationsAdherent">
							<ul>
								<li><b>Num adherent :</b> {$informations[0]['ad_num']}</li>
								<li><b>Nom :</b> {$informations[0]['ad_nom']}</li>
								<li><b>Prenom :</b> {$informations[0]['ad_prenom']}</li>
								<li><b>Adresse :</b> {$informations[0]['ad_num_rue']} {$informations[0]['ad_lib_rue']} {$informations[0]['ad_code_postal']} {$informations[0]['ad_ville']}</li>
								<li><b>Telephone :</b> {$informations[0]['ad_tel']}</li>
								<li><b>Mail :</b> {$informations[0]['ad_mail']}</li>
								<li><b>Date d'adhesion :</b> {$informations[0]['ad_dte_adhesion']}</li>
								<li><b>Actif :</b> $actif</li>
							</ul>
						</div>
					</div>
				</div>
HEREDOC;
		echo $html."</br>" ;
		}
		
		public function informationsModification(){
						$html=
<<<HEREDOC
<div id="menu">
	<h1>Informations</h1>
	<div class="nav">
		<dl>
			<dt><a href="./user_controller.php?action=informations">Mes informations</a></dt>
			<dt><a href="./user_controller.php?action=informationsModification">Modifiez informations</a></dt>
		</dl>
	</div>
</div>
<div id="contenu">
	<div id="header_page">
		<h1>Modification de vos Informations</h1>
	</div>
	<div id="contenu_page" class="soria">
		<FORM method="post" action="adefinir" id="formulaire" data-dojo-type="dijit.form.Form">
			<center/>
			<br/>
			<br/>
			<TABLE BORDER="0">			
				<tr>
					<td>
						<label>Num&eacute;ro de rue :</label>
					</td>
					<td>
						<input type='text' name='numRue' id='numRue' data-dojo-type="dijit.form.NumberTextBox" required="true" 
											constraints="{min:0,max:1000,places:0}" invalidMessage="numéro de rue incorrect"/>
					</td>
				</tr>
				<tr>
					<td>				
						<label>Rue :</label>
					</td>
					<td>
						<input type='text' name='rue' id='rue' data-dojo-type="dijit.form.TextBox" required="true" 
											data-dojo-props="trim:true, propercase:true" />
					</td>
				</tr>	
				<tr>
					<td>
						<label>Code Postal :</label>
					</td>
					<td>
						<input type='text' name='cp' id='cp' data-dojo-type="dijit.form.NumberTextBox" 
											required="true" constraints="{min:0,max:99999,places:0}" invalidMessage="code postal incorrect"/>
					</td>
				</tr>
				<tr>
					<td>				
						<label>Ville :</label>
					</td>
					<td>
						<input type='text' name='ville' id='ville' data-dojo-type="dijit.form.TextBox" required="true" 
											data-dojo-props="trim:true, propercase:true" />
					</td>
				</tr>
				<tr>
					<td>
						<label>Telephone :</label>
					</td>
					<td>
						<input type='text' name='tel' id='tel' data-dojo-type="dijit.form.NumberTextBox" required="true" 
											constraints="{pattern:'0000000000',max:9999999999,places:0}"/>
					</td>
				</tr>
				<tr>
					<td>
						<label>Adresse Mail</label>
					</td>
					<td>
						<input type="text" name="mail" id="mail" data-dojo-type="dijit.form.ValidationTextBox" required="true"  
											invalidMessage:'Invalid e-mail'"/>
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<br/>
						<br/>
						<center><button type="submit" data-dojo-type="dijit.form.Button" id="submitButton" onclick="sendForm('myform');">Enregistrer informations</button></center>
					</td>
				</tr>	
			</TABLE></center>
		</FORM>
	</div>
</div>

HEREDOC;
		echo $html."</br>" ;
		}

		
		///////////////Professeur/////////////
		public function contenu_planning(){

		
		$var = $this->getPlanning();
		
			$html=
<<<HEREDOC
			<div id="menu">
				<h1>Planning</h1>
				<div class="nav">
					<dl>
						<dt><a href="./user_controller.php?action=planning">Mon planning</a></dt>
					</dl>
				</div>
			</div>
			<div id="contenu">
				<div id="header_page">
					<h1>Mon planning</h1>
				</div>
				<div id="contenu_page">	
					$var
				</div>
			</div>
HEREDOC;
		echo $html."</br>";
		}
		

		
		//////////////Administration//////////
		public function coursGestion(){
			
			$var = $this->getPlanning();
			
			$html = 
			<<<HEREDOC
			<div id="menu">
				<h1>Cours</h1>
				<div class="nav">
					<dl>
						<dt><a href="./user_controller.php?action=CourGestion_modif">Modifier Cours</a></dt>
						<dt><a href="./user_controller.php?action=CoursGestion">Voir Planning</a></dt>
						<dt><a href="./user_controller.php?action=CoursGestion_ajout">Ajouter un cours </a></dt>
					</dl>
				</div>
			</div>
			<div id="contenu">
				<div id="header_page">
					<h1>Gestion des cours - Planning</h1>
				</div>
				<div id="contenu_page">	
				<div id="response"></div>
					$var
				</div>
			</div>
HEREDOC;
echo $html ;
					
		}
		
		public function coursGestion_modif(){
			Doctrine_Core :: loadModels('../models');
			$arrayProfesseurs = Doctrine_Core :: getTable ( 'Adherent' )->findBy('ad_level', 2 ,null);	
			$listeProfesseurs = $arrayProfesseurs->getData();
			
			$tabCours = $this->getAllCours();			
			
			$vue = "";
			
					foreach($tabCours as $cours){
						
					$nb = $this->getNombreAdCour($cours[6]);
					$taux = $nb/20*100 ;	
					
					
						$vue .= 
						"	
						<tr>  ";
									
							$vue .="<input type='hidden' name='cours_id' id='cours_id' value='".$cours[6]."' />
			              		 <td><input data-dojo-type='dijit.form.TextBox'  type='text' name='jour' id='jour".$cours[6]."' value= '".$cours[0]."'/></td>
			              		 <td><input data-dojo-type='dijit.form.TextBox'  type='text' name='heure' id='heure".$cours[6]."' value='".$cours[1]."'/></td>
			                     <td>".$nb."</td>
			                     <td>".$cours[2]."</td>
			                     <td>
			                     	<select name='professeur' id='professeur".$cours[6]."'>  
			                         <OPTION selected value='".$cours[3]."' id='".$cours[3]."' >".$cours[4]." ".$cours[5]." </OPTION>";
						foreach($listeProfesseurs as $professeur){
							 	
							if($professeur['ad_id'] != $cours[3]){
							$vue .= "<OPTION value='".$professeur['ad_id']."' id='".$professeur['ad_id']."' >".$professeur['ad_prenom']." ".$professeur['ad_nom']. "</OPTION>";
							}	
						}                     		
			             $vue .="                   
			                     	<select/>
			                   </td>
			                         		<td>".$taux."%"."</td>
			                         		<td>
			                         	<button onClick='modifCours(".$cours[6].");' type='submit' data-dojo-type='dijit.form.Button' >Valider</button>
			                         		</td>
			              				</tr>";
						
					}	
					
		
					
			$html = 
			<<<HEREDOC
			<div id="menu">
				<h1>Cours</h1>
				<div class="nav">
					<dl>
						<dt><a href="./user_controller.php?action=CourGestion_modif">Modifier Cours</a></dt>
						<dt><a href="./user_controller.php?action=CoursGestion">Voir Planning</a></dt>
						<dt><a href="./user_controller.php?action=CoursGestion_ajout">Ajouter un cours</a></dt>
					</dl>
				</div>
			</div>
			<div id="contenu">
				<div id="header_page">
					<h1>Gestion des cours - Modification des cours</h1>
				</div>
				<div id="contenu_page" class='soria'>	
				
				</br></br>
					<div id="response"></div>	
					<table class ='reportTable'>
                    	<thead>
                    		<tr>
        	    				<th class="enteteTab">Jours</th>
        	    				<th class="enteteTab">Heure</th>
             					<th class='enteteTab'>Nombre</th> 
             					<th class='enteteTab'>Type</th> 
             					<th class='enteteTab'>Professeur</th</tr>
             					<th class='enteteTab'>Taux</th>
             					<th class='enteteTab'>Modifer</th>
             				</tr> 
             			</thead>
             			<tbody>
             				$vue
           				</tbody>
           			</table>
           				
				</div>
			</div>
HEREDOC;
echo $html ;
		}
		
		public function coursGestion_ajout(){
				    include_once ('../orm/bootstrap.php');
					 Doctrine_Core :: loadModels('../models');
					$arrayDanse = Doctrine_Core :: getTable ( 'Danse' )->findAll(null);	
					$arrayNiveau = Doctrine_Core :: getTable ( 'Niveau' )->findAll(null);			
					$arrayProf = Doctrine_Core :: getTable ( 'Adherent' )->findBy('ad_level',2,null);	
					$prof = $arrayProf->getData();
					
					$prof_Select = "<select name='professeur' id='professeur'>";	
								
						for($i = 0 ; $i < count($prof) ; $i++){	
					
							$profData = $prof[$i]->getData();
							$prof_Select = $prof_Select.
							"<option  value=".$profData['ad_id'].">".$profData['ad_prenom']." ".$profData['ad_nom']."</option>" ;
							
						}
						$prof_Select = $prof_Select."</select>";
					$html = 
<<<HEREDOC
	<div id="menu">
				<h1>Cours</h1>
				<div class="nav">
					<dl>
						<dt><a href="./user_controller.php?action=CourGestion_modif">Modifier Cours</a></dt>
						<dt><a href="./user_controller.php?action=CoursGestion">Voir Planning</a></dt>
						<dt><a href="./user_controller.php?action=CoursGestion_ajout">Ajouter un cours</a></dt>
					</dl>
				</div>
			</div>
			<div id="contenu">
				<div id="header_page">
					<h1>Gestion des cours - Ajout d'un cours</h1>
				</div>
				<div id="contenu_page" class="soria">	
									<div id="response"></div>	
								
								<form action="../orm/coursData.php" id="ajout_cours" onsubmit="sendForm('ajout_cours');return false">
										   <TABLE BORDER="0">
							<tr>
								<td>				
								<label>Jours</label>
								</td>
								<td>
										<select name="jours" id="jours">	
										<option value="Lundi">Lundi</option>
										<option value="Mardi">Mardi</option>
										<option value="Mercredi">Mercredi</option>
										<option value="Jeudi">Jeudi</option>
										<option value="Vendredi">Vendredi</option>
										<option value="Samedi">Samedi</option>
										<option value="Dimanche">Dimanche</option>
										</select>
								</td>
							</tr>
							<tr>
								<td>				
									<label>Heure de début (format xxhxx) :</label>
								</td>
								<td>
									<input type="text" name="heure" id="heure" data-dojo-type="dijit.form.TextBox" required="true" 
												data-dojo-props="trim:true, propercase:true" />
								</td>
							</tr>				
							<tr>
								<td>
									<label>Niveau</label>
								</td>
								<td>
									<select name="niveau" id="niveau">	
										<option value="1">Découverte</option>
										<option value="2">Apprentissage</option>
										<option value="3">Technique</option>
										<option value="4">Atelier</option>
									</select>
								</td>
							</tr>
							<tr>
								<td>				
									<label>Danse</label>
								</td>
								<td>
									<select name="danse" id="danse">	
										<option value="1">Classique</option>
										<option value="2">Moderne</option>
										<option value="3">Salsa</option>
										<option value="4">Tango</option>										
										<option value="5">Zumbo</option>
									</select>
								</td>
							</tr>	
							<tr>
								<td>
									<label>Professeur :</label>
								</td>
								<td>
									$prof_Select
								</td>
							</tr>
						
						</TABLE></br>
						<center><button type="submit" data-dojo-type="dijit.form.Button" id="submitButton" >Valider</button></center>										
			    	</form>					
				</div>
			</div> 
HEREDOC;
echo $html ;
		}
		
		
		public function ProfesseurGestion(){
			
			$listeProfesseurs = $this->getProfesseurs();
			
			$html = 
<<<HEREDOC
			<div id="menu">
				<h1>Professeurs</h1>
				<div class="nav">
					<dl>
						<dt><a href="./user_controller.php?action=ProfesseurGestion">Liste des professeurs</a></dt>
						<dt><a href="./user_controller.php?action=ProfesseurGestion_ajouter">Ajouter professeur</a></dt>
					</dl>
				</div>
			</div>
			<div id="contenu">
				<div id="header_page">
					<h1>Gestion des professeurs - Liste</h1>
				</div>
				<div id="contenu_page">	
				<div id="response"></div>	
					</br></br>
						<table class ='reportTable'>
                    		<thead>
                    			<tr>
        	    					<th class="enteteTab">Nom</th>
             						<th class='enteteTab'>Nombre de cours</th> 
             						<th class='enteteTab'>Suppression</th>
             					</tr> 
             				</thead>
             				<tbody>
             					$listeProfesseurs
           					</tbody>
           				</table>
					</div>
				</div>
HEREDOC;
			echo $html ;
		}
			
		public function ProfesseurGestion_ajouter(){
			$html=
<<<HEREDOC
			<div id="menu">
				<h1>Professeurs</h1>
				<div class="nav">
					<dl>
						<dt><a href="./user_controller.php?action=ProfesseurGestion">Liste des professeurs</a></dt>
						<dt><a href="./user_controller.php?action=ProfesseurGestion_ajouter">Ajouter professeur</a></dt>
					</dl>
				</div>
				</div><div id="contenu">
					<div id="header_page">
						<h1>Gestion des professeurs - Ajout d'un professeur</h1>
					</div>
					<div id="contenu_page" class="soria">										
						<div id="response"></div>	
						<form action="../orm/userData.php" onSubmit="sendForm('myform');return false;" id="myform">
							<TABLE BORDER="0">
								<tr>
									<td>				
										<label>Nom :</label>
									</td>
									<td>
										<input type="text" name="nom" id="nom" data-dojo-type="dijit.form.TextBox" required="true" 
														data-dojo-props="trim:true, propercase:true" />
									</td>
								</tr>
								<tr>
									<td>				
										<label>Pr&eacute;nom :</label>
									</td>
									<td>
										<input type="text" name="prenom" id="prenom" data-dojo-type="dijit.form.TextBox" required="true" 
														data-dojo-props="trim:true, propercase:true" />
									</td>
								</tr>				
								<tr>
									<td>
										<label>Num&eacute;ro de rue :</label>
									</td>
									<td>
										<input type="text" name="numRue" id="numRue" data-dojo-type="dijit.form.NumberTextBox" required="true" 
														constraints="{min:0,max:1000,places:0}" invalidMessage="numéro de rue incorrect"/>
									</td>
								</tr>
								<tr>
									<td>				
										<label>Rue :</label>
									</td>
									<td>
										<input type="text"" name="rue" id="rue" data-dojo-type="dijit.form.TextBox" required="true" 
														data-dojo-props="trim:true, propercase:true" />
									</td>
								</tr>	
								<tr>
									<td>
										<label>Code Postal :</label>
									</td>
									<td>
										<input type="text" name="cp" id="cp" data-dojo-type="dijit.form.NumberTextBox" 
														required="true" constraints="{min:0,max:99999,places:0}" invalidMessage="code postal incorrect"/>
									</td>
								</tr>
								<tr>
									<td>				
										<label>Ville :</label>
									</td>
									<td>
										<input type="text" name="ville" id="ville" data-dojo-type="dijit.form.TextBox" required="true" 
														data-dojo-props="trim:true, propercase:true" />
									</td>
								</tr>
								<tr>
									<td>
										<label>Telephone :</label>
									</td>
									<td>
										<input type="text" name="tel" id="tel" data-dojo-type="dijit.form.NumberTextBox" required="true" 
														constraints="{pattern:'0000000000',max:9999999999,places:0}"/>
									</td>
								</tr>
								<tr>
									<td>
										<label>Adresse Mail</label>
									</td>
									<td>
										<input type="text" name="mail" id="mail" data-dojo-type="dijit.form.ValidationTextBox" required="true" />
									</td>
								</tr>							
								<tr>
									<td>							
										<label>Mot de passe</label>						 
									</td>								
									<td>
										 <input name="password_1" id="password_1" type="password" dojoType="dijit.form.TextBox" />
									</td>
								</tr>
								<tr>
									<td>								
										 <label>Confirmer mot de passe</label>								 							   
									</td>
									<td>
										 <input name="password_confirme" id="password_confirme" type="password" dojoType="dijit.form.TextBox" />
									</td>
								</tr>
								<tr>
									<td colspan="2">
										<br/>
										<br/>
										<center>
									</td>
								</tr>
								<input type="hidden"  name="level" id="level" value="2"/>
							</TABLE>
							<center><button type="submit" data-dojo-type="dijit.form.Button" id="submitButton" >Valider</button></center>
						</form>									
						<br>
					</div>
				</div>
HEREDOC;
				
			echo $html."<br/>";
		}
		
		public function AdherentGestion(){	
			
			$listeAdherents = $this->getAdherents();
			
			$html=
<<<HEREDOC
			<div id="menu">
				<h1>Adhérents</h1>
				<div class="nav">
					<dl>
						<dt><a href="./user_controller.php?action=AdherentGestion">Liste des adhérents</a></dt>
					</dl>
				</div>
			</div>
			<div id="contenu">
				<div id="header_page">
					<h1>Gestion des adhérents - Liste des adhérents</h1>
				</div>
				<div id="contenu_page" class="soria">
					</br>
					
					</br>
					<div id='response' ></div>
						<table class ='reportTable'>
                    		<thead>
                    			<tr>
        	    					<th class="enteteTab">Nom</th>
        	    					<th class="enteteTab">Actif</th>
             						<th class='enteteTab'>Cours inscrits</th> 
             						<th class='enteteTab'></th>
             					</tr> 
             				</thead>
             				<tbody>
             					$listeAdherents
           					</tbody>
           				</table>
								</div>
							</div>
HEREDOC;
			
			echo $html."<br/>";
		}
		

		public function getAdherents(){	
			
			Doctrine_Core :: loadModels('../models');
			$arrayAdherents = Doctrine_Core :: getTable ( 'Adherent' )->findBy('ad_level', 1 ,null);	
			$listeAdherents = $arrayAdherents->getData();
			$liste = " ";
			
			foreach ($listeAdherents as $adherent){
				$var = $this->getListeCoursAdherentById($adherent['ad_id']);
				$coursL = "";
				foreach($var as $cours){				
				$coursL = $coursL."<option value=".$cours[0].">".$cours[0]." ".$cours[1]." ".$cours[2]." ".$cours[3]." </option>";
				}
				
				$liste = $liste.
"<tr>
    <td>".$adherent["ad_prenom"]." ".$adherent ["ad_nom"]."</td>
	<td><center>
	<select  id='actif".$adherent['ad_id']."' >
			<option value=".$adherent["ad_est_actif"]." >".$adherent["ad_est_actif"]." </option>";
				if($adherent["ad_est_actif"] != 1){
					$liste = $liste."<option value =1 >1</option>";					
				}else{
					$liste = $liste."<option value =0 >0</option>";
				}
				
	$liste = $liste."</select>
	</center></td>".
    "<td>
		<select name='liste_cours_adherent' id='liste_cours_adherent'>".
			$coursL.
		"</select>
    </td>
     <td><center><input type='button' value='Modifer' onClick='modifAdherent(".$adherent['ad_id'].");' /></center></td>
</tr>";
			}
			return $liste;
		}
		
		public function getUserById($id){
			
			Doctrine_Core :: loadModels('../models');
			$user = Doctrine_Core :: getTable ( 'Adherent' )->findBy('ad_id', $id ,null);	
			$user = $user->getData();
			return $user;
		}
		
		public function getListeCoursAdherentById($id){
			
			Doctrine_Core :: loadModels('../models');
			$arrayCours = Doctrine_Core :: getTable ( 'Inscrit' )->findBy('ad_id', $id ,null);	
			$arrayCours = $arrayCours->getData();
			$listeCours = array();
			for($i=0; $i<count($arrayCours); $i++){
				$cours = Doctrine_Core :: getTable ( 'Cours' )->findBy('cours_id', $arrayCours[$i]['cours_id'] ,null);	
				$cours = $cours->getData();
				$niveau = Doctrine_Core :: getTable ( 'Niveau' )->findBy('niv_id', $cours[0]['niv_id'] ,null);
				$niveau = $niveau->getData();
				$danse = Doctrine_Core :: getTable ( 'Danse' )->findBy('danse_id', $cours[0]['danse_id'] ,null);
				$danse = $danse->getData();
				$val = $i;

                        	
				$listeCours[$i] = array($cours[0]['cours_jour'],$cours[0]['cours_heure'],$niveau[0]['niv_lib'],$danse[0]['danse_lib'],$cours[0]['cours_id']);
				
			}
	
			return $listeCours;
		}
		
		public function inscrireCoursByAdherent($id , $coursId){
			
			Doctrine_Core :: loadModels('../models');			
			$user = new Adherent();
			$user = $this->getUserById($id);
			if($user[0]['ad_cours_semaine'] < 4){
				$inscrit = new Inscrit();
				$inscrit['ad_id'] = $id;
				$inscrit['cours_id'] = $coursId;
				$inscrit->save();
				$user[0]['ad_cours_semaine'] = $user[0]['ad_cours_semaine'] + 1;
				$user[0]->save();
			}
	
			$this->inscription_cours();
		}
		
		public function desincrireCoursByAdherent($id, $coursId){
			
			Doctrine_Core :: loadModels('../models');		
			$arrayCours = Doctrine_Core :: getTable ( 'Inscrit' )->findBy('ad_id', $id , null);
			$arrayCours = $arrayCours->getData();	
			foreach ($arrayCours as $cours){
				if($cours['cours_id'].'/' == $coursId){
					$cours->delete();
					$user = $this->getUserById($id);
					$user[0]['ad_cours_semaine'] = $user[0]['ad_cours_semaine'] - 1;
					$user[0]->save();
				}
			}
		}
		
		public function getProfesseurs(){
			
			Doctrine_Core :: loadModels('../models');
			$arrayProfesseurs = Doctrine_Core :: getTable ( 'Adherent' )->findBy('ad_level', 2 ,null);	
			$listeProfesseurs = $arrayProfesseurs->getData();
			$liste = " ";
			
			foreach ($listeProfesseurs as $professeur){
				$var = $this->getListeCoursProfesseurById($professeur['ad_id']);
				$liste = $liste.
				"<tr>
					<td>".$professeur["ad_prenom"]." ".$professeur["ad_nom"]."</td>
		    		<td>
						<select name='liste_cours_professeurs' id='liste_cours_professeurs'>".
							$var.
						"</select>
		    		</td>
					<td><center><input type='button' value='Supprimer' onClick='deleteProf(".$professeur['ad_id'].")'/></center></td>
				</tr>";
			}
			return $liste;
		}
		
		
		public function getNombreAdCour($id){
			Doctrine_Core :: loadModels('../models');
		    $array = Doctrine_Core :: getTable ( 'Inscrit' )->findBy('cours_id',$id,null);	
		    $tableauNb = $array->getData();
		    return count($tableauNb);	
		}
		
		public function getAllCours(){
					 Doctrine_Core :: loadModels('../models');
					 $array = Doctrine_Core :: getTable ( 'Cours' )->findAll(null);			
					 		
					
					$tableauCours = $array->getData();
					
					$tabCoursComplet = array();
					for($i = 0 ; $i < count($tableauCours) ; $i++){	 
					$cours = $tableauCours[$i]->getData();	
			
					$arrayDanse = Doctrine_Core :: getTable ( 'Danse' )->findBy('danse_id',$cours['danse_id'],null);	
					$arrayNiveau = Doctrine_Core :: getTable ( 'Niveau' )->findBy('niv_id',$cours['niv_id'],null);			
					$arrayProf = Doctrine_Core :: getTable ( 'Adherent' )->findBy('ad_id',$cours['ad_id'],null);
						
				    $danse = $arrayDanse->getData();	
					$danse = $danse[0]->getData();
					
					$niveau = $arrayNiveau->getData();
					$niveau = $niveau[0]->getData();
					
					$prof = $arrayProf->getData();
					$prof = $prof[0]->getData();
					
					$tabCoursComplet[$i] = array($cours['cours_jour'],$cours['cours_heure'],$danse['danse_lib'],$prof['ad_id'],$prof['ad_nom'],$prof['ad_prenom'],$cours['cours_id'],$niveau['niv_lib']);

			}
			return $tabCoursComplet ; 
		}
		
		public function getListeCoursProfesseurById($id){
			
			Doctrine_Core :: loadModels('../models');
			$cours = Doctrine_Core :: getTable ( 'Cours' )->findBy('ad_id', $id ,null);	
			$cours = $cours->getData();
			$listeCours = " ";
			for($i=0; $i<count($cours); $i++){
				$niveau = Doctrine_Core :: getTable ( 'Niveau' )->findBy('niv_id', $cours[$i]['niv_id'] ,null);
				$niveau = $niveau->getData();
				$danse = Doctrine_Core :: getTable ( 'Danse' )->findBy('danse_id', $cours[$i]['danse_id'] ,null);
				$danse = $danse->getData();
				$val = $i+1;
				$listeCours = $listeCours."<option value=".$val.">".$cours[$i]['cours_jour']." ".$cours[$i]['cours_heure']." ".$niveau[0]['niv_lib']." ".$danse[0]['danse_lib']."</option></br>";
			}
			return $listeCours;
		}
				
		public function getPlanning(){
			
					 Doctrine_Core :: loadModels('../models');
					 $array = Doctrine_Core :: getTable ( 'Cours' )->findAll(null);			
					 		
					
					$tableauCours = $array->getData();
					
					for($i = 0 ; $i < count($tableauCours) ; $i++){	 
						$cours = $tableauCours[$i]->getData();	
							switch	(strtolower($cours['cours_jour'])) {
									case 'lundi' : $jour = 1 ;
									break;
									case 'mardi' : $jour = 2 ;
									break ;
									case 'mercredi' : $jour = 3 ;
									break ;
									case 'jeudi' : $jour = 4 ;
									break ;
									case 'vendredi' : $jour = 5 ;
									break ;
									case 'samedi' : $jour = 6 ;
									break ;
									case 'dimanche' : $jour = 7 ;
									break;	
							}
					$arrayDanse = Doctrine_Core :: getTable ( 'Danse' )->findBy('danse_id',$cours['danse_id'],null);	
					$arrayNiveau = Doctrine_Core :: getTable ( 'Niveau' )->findBy('niv_id',$cours['niv_id'],null);			
					$arrayProf = Doctrine_Core :: getTable ( 'Adherent' )->findBy('ad_id',$cours['ad_id'],null);	
				    $danse = $arrayDanse->getData();	
					$danse = $danse[0]->getData();
					$niveau = $arrayNiveau->getData();
					$niveau = $niveau[0]->getData();
					$prof = $arrayProf->getData();
					$prof = $prof[0]->getData();
					$heure = str_replace('h',':',$cours['cours_heure']);

					if(strlen($heure) == 4){
						$h = $heure[0];
						$h++;
						$heure_fin =$h.$heure[1].$heure[2].$heure[3];  
					}else {
						$h = $heure[0].$heure[1];
						$h++ ;						
						$heure_fin =$h.$heure[2].$heure[3].$heure[4];				
					}
					$contenusCellules[] = new PlanningCellule($jour,$heure,$heure_fin,'#80C080',$danse['danse_lib']."</br>".$prof['ad_nom']." ".$prof['ad_prenom']."</br>".$niveau['niv_lib']);		
					}	
			if(isset($contenusCellules)){			
				$planning = new Planning(1, 7, 480, 1080, 30, $contenusCellules);
				$plan = $planning->afficherHtmlTable();
				return $plan ;
			}else{
				
				return "Il n'y a pour le moment aucun cours";
		}
		}	
		
		public function setUserLevel($user_level)
		{
			$this->user_level = $user_level;
		}
	}
?>